package cn.liulingfengyu.structuralpattern.compositepattern;

import java.util.Collections;
import java.util.List;

/**
 * 叶子节点类
 */
public class Leaf implements Component {
    private String name;

    public Leaf(String name) {
        this.name = name;
    }

    @Override
    public void add(Component component) {
        // 叶子节点无法添加子节点
    }

    @Override
    public void remove(Component component) {
        // 叶子节点无法移除子节点
    }

    @Override
    public List<Component> getChildren() {
        // 叶子节点没有子节点
        return Collections.emptyList();
    }

    @Override
    public void operation() {
        System.out.println("叶子节点 " + name + " 的操作");
    }
}